from rest_framework.serializers import ModelSerializer
from admincharge.models import ChargeAdmin, PetMessage, PetOwner, FosterPet, SellPet, ShopGoods
from NetShop.models import CustomLogin, Address, Order
from rest_framework import serializers
from rest_framework_simplejwt.serializers import TokenObtainPairSerializer


# 管理员登录数据
class ShopAdminLoginSearilizer(ModelSerializer):
    created_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S')

    class Meta:
        model = ChargeAdmin
        fields = ['id','username', 'password', 'nick_name', 'sex', 'status', 'created_time', 'is_active','is_super','mobile']



# 宠物基本信息
class PetMessageSerializer(ModelSerializer):
    petvaccinestime = serializers.DateTimeField(format='%Y-%m-%d')

    class Meta:
        model = PetMessage
        fields = "__all__"


# 顾客信息
class CustomMessageSerializer(ModelSerializer):
    created_time = serializers.DateTimeField(format='%Y-%m-%d')

    class Meta:
        model = PetOwner
        fields = "__all__"


# 寄养
class FosterMessageSerializer(ModelSerializer):
    foster_start_time = serializers.DateTimeField(format='%Y-%m-%d')
    foster_end_time = serializers.DateTimeField(format='%Y-%m-%d')
    class Meta:
        model = FosterPet
        fields = '__all__'


class SellPetSerializer(ModelSerializer):
    create_time = serializers.DateTimeField(format='%Y-%m-%d')

    class Meta:
        model = SellPet
        fields = '__all__'


class ShopGoodsSerializer(ModelSerializer):
    create_time = serializers.DateTimeField(format='%Y-%m-%d')
    end_time = serializers.DateTimeField(format='%Y-%m-%d')

    class Meta:
        model = ShopGoods
        fields = '__all__'


class CustomLoginMessageSerializer(ModelSerializer):
    created_time = serializers.DateTimeField(format='%Y-%m-%d')

    class Meta:
        model = CustomLogin
        fields = '__all__'


class ChargeAddressSerializer(ModelSerializer):
    class Meta:
        model = Address
        fields = '__all__'


class OrderSerializer(ModelSerializer):
    order_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M')
    class Meta:
        model = Order
        fields = '__all__'
